<template>
    <div class="app-container">
        <h5 style="margin-top: 15px">这里我们使用window.print（）来实现下载PDF的功能。</h5>

        <router-link target="_blank" to="/example/pdfDownload">
            <el-button type="primary" class="down-btn">单击下载PDF --- /example/pdfDownload</el-button>
        </router-link> 
        <el-button type="primary" size="default" v-permission="['admin', 'editor']">这是一个按钮 通过指令 v-permission="['admin', 'editor']" 来判断显示</el-button> 
        <el-button type="primary" size="default" v-permission="['admin1', 'editor1']">这是一个按钮 通过指令 v-permission="['admin', 'editor']" 来判断显示</el-button> 
        <el-button type="primary" size="default" v-if="hasPermission(['admin', 'editor'])">这是一个按钮，通过调用hasPermission来判断显示</el-button> 
        <el-button type="primary" size="default" v-if="hasPermission(['admin2', 'editor2'])">这是一个按钮，通过调用hasPermission来判断显示</el-button>
    </div>
</template>

<script>
// import permission from '@/directive/permission/index.js';
import hasPermission from '@/utils/permission.js';
export default {
    name: 'pdfIndex',
    // directives: {permission},
    mounted() {
        for (let i = 0; i < 10; i++) {
            let isTrue = Math.random() > 0.5;
            if (isTrue) {
                this.assignParams({pageSize: parseInt(Math.random() * 10)});
            } else {
                this.assignParams();
            }
        }
    },
    methods: {
        hasPermission,
        assignParams(params = {}) {
            // let newParams = Object.assign({pageSize: 1, pageNum: 10}, params);
            let newParams = {pageSize: 1, pageNum: 10,...params};
            console.log(JSON.stringify(newParams));
        }
    },
};
</script>
<style lang="scss" scope>
.app-container {
    margin: 20px;
    background: #fff;
    border-radius: 20px;
    padding: 20px;
    .el-button{
        margin: 10px;
    }
}
</style>
